package org.jproxy.json;

class SimpleJSONObject implements JSONObject
{
	private JSONAttribute attribute;
	private Type type;

	SimpleJSONObject(String name, String value, Type type)
	{
		attribute = new JSONAttribute(name, value);
		this.type = type;
	}

	@Override
	public JSONAttribute getAttribute()
	{
		return attribute;
	}

	@Override
	public JSONAttribute getAttribute(String name)
	{
		if(name.equals(attribute.getName()))
			return attribute;
		return null;
	}

	@Override
	public Type getType()
	{
		return type;
	}

	@Override
	@SuppressWarnings("unchecked")
	public <T> T toObject(Class<T> clazz)
	{
		return attribute.getValue(clazz);
	}

}
